﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rectangle
{
    public class Rectangle : IComparable, ICloneable
    {
        private int leftDownX = 0;
        private int leftDownY = 0;
        private int width = 0;
        private int height = 0;

        public int LeftDownX
        {
            get { return this.leftDownX; }
            set { this.leftDownX = value; }
        }
        public int LeftDownY
        {
            get { return this.leftDownY; }
            set { this.leftDownY = value; }
        }
        public int Width
        {
            get { return this.width; }
        }
        public int Height
        {
            get { return this.height; }
        }

        public Rectangle(int leftDownX, int leftDownY, int width, int height)
        {
            if (width < 0 || height < 0)
            {
                throw new ArgumentException("width and height of the rectangle cannot be negative numbers");
            }
            this.leftDownX = leftDownX;
            this.leftDownY = leftDownY;
            this.width = width;
            this.height = height;
        }

        public int Area()
        {
            return this.width * this.height;
        }

        public int CompareTo(object obj)
        {
            Rectangle rectangle = (Rectangle)obj;
            return this.Area().CompareTo(rectangle.Area());
        }

        public object Clone()
        {
            return new Rectangle(this.leftDownX, this.leftDownY, this.width, this.height);
        }
    }
}
